<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * 微信群发主表
 * @package App\Models
 */
class WxMass extends Model
{
    use SoftDeletes;
    //表名
    protected $table = 'wx_mass';
    //主键
    protected $primaryKey = 'mass_id';
    protected $dateFormat = 'Y-m-d H:i:s';
    /**
     * 需要转换成日期的属性
     * @var array
     */
    protected $dates = [
        'push_time',
    ];
    /**
     * 应该被转换成原生类型的属性。
     * @var array
     */
    protected $casts = [
        'filter_rule' => 'array'
    ];
    /**
     * 素材数据
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function material()
    {
        return $this->hasOne('App\Models\WxMaterial','material_id', 'material_id');
    }

    /**
     * 群发结果
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function result()
    {
        return $this->hasOne('App\Models\WxMassResult','msg_id', 'msg_id');
    }
    /**
     * 群发文章列表
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function articles()
    {
        return $this->hasMany('App\Models\WxMassArticle','msg_id', 'msg_id');
    }
}
